<!-- Le Site du coffre > Les news > Accueil -->
<!-- <h1>Les 10 dernières news du site</h1> -->
<?php 
//echo '<p class="pagination">';
// On récupère les 5 dernières news + le pseudo qui à posté la news
$news = $pdo->query("SELECT COUNT(*) as nbr FROM forum_topic");
$n = $news->fetch();
$nbForumPost = $n['nbr'];
$limitForumPost = 5;

$pdo->query("SET NAMES UTF8");
$retour = $pdo->prepare('SELECT * FROM forum_topic JOIN forum_forum ON forum_forum.forum_id=forum_topic.forum_id JOIN forum_categorie ON cat_id=forum_cat_id JOIN forum_post ON forum_topic.topic_id=forum_post.topic_id WHERE cat_level <= ? GROUP BY forum_topic.topic_titre ORDER BY post_time DESC LIMIT 5');
$retour->execute(array(id2level()));

$dev = 0;
$max1 = 70; //Nombre de caractére maximum à afficher pour la premiere news


		
while ($donnees = $retour->fetch())
{
	
	if(strtotime('+2 day', $donnees['topic_time'])<time())
        $class = "normal";
    else
        $class = "date_news_couleur";
	
	
	$nb = $pdo->query('SELECT * FROM forum_post WHERE topic_id='.intval($donnees['topic_id']));
		if($retour->rowCount() < 10)
			$num = 1;
		else
			$num = ceil($retour->rowCount()/10);
			
		$fvquery = 'SELECT * FROM forum_forum_view JOIN forum_post ON fv_post_id=post_id WHERE fv_membre_id=? AND fv_topic_id=? AND fv_post_id=?';
		$fv = $pdo->prepare($fvquery);
		
		if(isset($_SESSION['id']))
			$fv->execute(array($_SESSION['id'],$donnees['topic_id'],$donnees['post_id']));
		else
			$fv->execute(array(-1,$donnees['topic_id'],$donnees['post_id']));
			
		if(!$fv->rowCount()){
				$syslu = '<img src="'.DIR_DESIGN.'/'.getDesignName().'/images/forum/non_lu.gif" title="Nouvelles réponses" height="15" width="20"/>';
				if(isset($_SESSION['id'])){
					$delete = $pdo->prepare("DELETE FROM forum_forum_view WHERE fv_membre_id=? AND fv_topic_id=?");
					$delete->execute(array($_SESSION['id'],$donnees['topic_id']));
				}
		}
			else
				$syslu = '<img src="'.DIR_DESIGN.'/'.getDesignName().'/images/forum/lu.gif" title="Pas de nouvelles réponses" height="20" width="22"/>';
				
	//$infoPost = $nb->fetch();		
echo '</p>';
	 /* $reponse = $pdo->prepare("SELECT COUNT(*) as nbr FROM commentaires_tutos WHERE id_tuto=?");
	  $reponse->execute(array($donnees['id']));
	  $r = $reponse->fetch();
	  $donnees2 = $r['nbr'];
	  */
	 // if($dev == 0){
		 
		 /*<span style="font-size:10px;"><?php echo format_temps( $donnees['topic_time'] ). ' par ' . sex2color(id2sex($donnees['topic_forum_membre_id']),$donnees['topic_forum_membre_id']);?>
<br />
<!-- Dernière réponse par <?php echo sex2color(id2sex($donnees['forum_membre_id']),$donnees['forum_membre_id']); ?> -->
</span>*/
?>

<?php
		echo $syslu . '&nbsp;';
		
	if($donnees['cat_level'] > MEMBRE)
		echo '(Topic ' . groupe2name($donnees['cat_id']) . ') ';
?>

<span class="<?php echo $class; ?>">
<a href="<?php echo getLienModule("forum","voirmessage"); ?>?fid=<?php echo $donnees['forum_id']; ?>&amp;tid=<?php echo $donnees['topic_id']; ?>&num=<?php echo $num; ?>#<?php echo $donnees['post_id']; ?>" title="Lire ce topic">

<?php 

$ttl = substr($donnees['topic_titre'],0,100);

echo htmlspecialchars((strlen($ttl)>95)?$ttl.'...':$ttl); ?></a>

</span>

<br />
publié

<span style="font-size:10px;"><?php echo format_temps( $donnees['post_time'] ). ' par ' . sex2color(id2sex($donnees['forum_membre_id']),$donnees['forum_membre_id']);?>

<!-- Dernière réponse par <?php echo sex2color(id2sex($donnees['forum_membre_id']),$donnees['forum_membre_id']); ?> -->
</span>




		<?php 
			//Com's
			/*
		echo '<div class="text_commentaire">';
	  $total = $donnees2;
	  
	   $total = ($total==0) ? "0" : $total;
	   echo '<a href="'.getLienModule("tuto","view").'?tutoid='.$donnees['id'].'#comment" title="'.$total.' commentaire(s)" alt="' .$total . ' commentaire(s)">' . $total;
	  ?>&nbsp;<img src="<?php echo DIR_DESIGN."/".getDesignName()."/images/bulle.png"; ?>" border="0" /></a></div>

*/ ?>

<?php


 }//}

 	if($retour->rowCount()<1)
		echo "Aucun topic pour le moment !";
		
	if($nbForumPost > $limitForumPost)
		if($_SESSION['id'])
{
echo '<div class="texte_centrer"><a href="'.getLienModule("forum","index").'" title="">Voir plus de topic</a></div>';
} else {
    $_str .= '';
}?>


<?php
/*
echo '<p class="pagination">';
echo get_list_page($page,$nombreDePages,'',50);
echo "</p>";
*/
?>